Modern platform-independent high-level programming languages, such as Java™ and C++, have significant market presence in the computing industry. Typically, programs written in these languages execute in a managed runtime environment (MRE) that provide automatic memory management, type management, thread and synchronization, and dynamic loading facilities.
MREs typically support just-in-time (JIT) compilation. The programs written in high-level programming languages are generally first compiled in codes in a platform-neutral distribution called bytecode. Bytecode is not machine code for any particular computer, and may be portable among computer architectures. The JIT compiler reads the bytecode in many sections and compiles them dynamically into machine language so that the program can run faster (optimized).
In some cases, the optimizations performed by the MRE in compiling bytecode may be unsafe (e.g., a misprediction). For instance, if a memory instruction is reordered, the optimization may be correct most of the time and performance may be improved, but at some point the optimization's assumptions may not hold. The MRE generally handles these mispredictions in the optimizations by discarding the speculative version and falling back to a pessimized version of the code. A problem with this approach is that the processor may lose performance because some optimizations are safe most of the time, with rare occurrence of mispredictions, so it is better not to pessimize these optimizations.